<template>
  <div>
    <VideoDetail :isEdit="false" :hasChanged="handleValueChange"></VideoDetail>
  </div>
</template>

<script>
import Head from "@/components/common/Head";
import VideoDetail from "@/components/video/VideoDetail";
export default {
  components: { Head, VideoDetail },
  data: {
    return:{
      changed: false,
    }
  },
  beforeRouteLeave(to, from, next) {
    if (this.changed === true) {
      this.$confirm('离开页面本页面中所有未提交的数据都会丢失', '警告', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      next();
    }).catch(() => {
      window.history.go(1);
    })
    } else {
      // 没做变动就直接跳转
      next();
    }
    
  },
  methods: {
    handleValueChange(data) {
      this.changed = true;
    }
  }
}
</script>

<style lang="sass" scoped>
</style>